package com.ccx.coachsite.ui.customview;

import com.ccx.coachsite.downloadmgr.AsyncImageLoaderStatic;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;

public class WebImageView extends ImageView {

	public WebImageView(Context context) {
		super(context);
	}

	public WebImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	private String url;

	public void setUrl(String url) {
		this.url = url;
		Drawable cache = AsyncImageLoaderStatic.loadDrawable(url,
				new AsyncImageLoaderStatic.ImageCallback() {

					@Override
					public void imageLoaded(Drawable imageDrawable,
							String imageUrl) {
						if (imageDrawable != null)
							WebImageView.this.setImageDrawable(imageDrawable);
					}
				});
		if (cache != null)
			super.setImageDrawable(cache);
	}

	public String getUrl() {
		return url;
	}
}
